package com.mqz.seal.v1.prs;

import java.awt.Font;

import com.mqz.seal.v1.prs.model.SealDTO;
import com.mqz.seal.v1.prs.rule.PrivateSealBuilder;
import com.mqz.seal.v1.prs.utils.ImageTest;

import cn.hutool.core.img.FontUtil;
import sun.font.FontDesignMetrics;


public class ZMainIn {

    public static void main(String[] args) throws Exception {

//        /** 构建请求参数 */
//        SealDTO dto = new SealDTO()
//                .setColorTag(1)
//                .setFontContent("萌章章")
//                .setFontFamilyTag(1);
//
//        PrivateSealBuilder ps = new ZFXSeal();
//        String path = ps.handleToLocal(dto);
//        System.out.println(path);
//
//
//        PrivateSealBuilder ps = new ZFXSeal();
//        SealDTO dto1 = new SealDTO()
//                .setColorTag(1)
//                .setFontContent("萌章章")
//                .setFontFamilyTag(1);
//        String base64 = ps.handleToBase64(dto1);
//        System.out.println(base64);

//        SealDTO dto = new SealDTO()
//                .setColorTag(1)
//                .setFontContent("蒙大拿")
//                .setFontFamilyTag(1)
//                .setFontSize(80);
//        PrivateSealBuilder ps = new CFXSeal();
//        String path = ps.handleToLocal(dto);
//        System.out.println(path);
    	
    	//String name = "巴哈古丽。热合曼";
    	//String name = "第力下提.帕尔哈提";
    	//String name = "第力下提.帕尔哈";
    	
    	//String name = "第力下提.帕尔";
    	
    	//String name = "第力下提帕尔";
    	
    	//String name = "第力下提帕";
    	//String name = "第力下提";
    	//String name = "第力下";
    	String name = "第力";
    	
    	Integer totalSize = ZFXSeal.imageSize;
    	Integer eachSize = 0;
    	//if(name.contains(".")) {
    	//	eachSize = totalSize/(name.length()-1);
    	//}else {
    	//	eachSize = totalSize/name.length();
    	//}
    	if(name.length() >= 5) {
    		eachSize=40;
    	}else {
    		eachSize=80;
    	}
    	
    	System.out.println(eachSize);
    	System.out.println(name);
    	
    	//FontUtil.createFont(name, size)

    	//计算一个字的宽度和度
    	//Font font = new Font("微软雅黑", Font.BOLD, eachSize);
    	//int width = ImageTest.getWordWidth(font, "你");
    	//FontDesignMetrics metrics = FontDesignMetrics.getMetrics(font);
    	//int height = metrics.getHeight();//计算高
    	
    	//System.out.println("width:"+width);
    	//System.out.println("height:"+height);
    	
        SealDTO dto = new SealDTO()
                .setColorTag(1)
               // .setFontContent("巴哈古丽.热合曼")
                .setFontContent(name)
                .setFontFamilyTag(1)
                .setNo("6501020284113")
                .setFontSize(eachSize);
        PrivateSealBuilder ps = new ZFXSeal();//画正方形    CFXSeal 为长方形
        
       String path = ps.handleToBase64(dto);
       System.out.println(path);
    }

}
